package cn.hxsteel.storage.core.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 文件上传服务
 */
@WebServlet( "/upload" )
public class UploadServlet extends HttpServlet
{
    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost( HttpServletRequest request, HttpServletResponse response )
	    throws ServletException, IOException
    {
	// try
	// {
	// SmartUpload mySmartUpload = new SmartUpload();
	// mySmartUpload.initialize( getServletConfig(), request, response );
	// mySmartUpload.upload();
	// Files files = mySmartUpload.getFiles();
	// int num = files.getCount();
	// for ( int i = 0; i < num; i++ )
	// {
	// com.jspsmart.upload.File myfile = files.getFile( i );
	// String fileName = myfile.getFileName();
	// fileName = new String( fileName.getBytes(), "UTF-8" );// 强转成UTF8不然中文文件名会是乱码
	// myfile.saveAs( "/store/" + fileName, i + 1 );
	// }
	// String ret = "保存成功";
	// byte[] rep = ret.getBytes();
	// response.getOutputStream().write( rep );
	// }
	// catch ( SmartUploadException e )
	// {
	// e.printStackTrace();
	// }
    }
}
